using UnityEngine;

namespace player
{
    public class JumpState : State
    {
        [SerializeField] float force;

        // ========================================================================

        public override void Enter()
        {
            base.Enter();

            player.SetVelocity(player.GetVelocity(0), force);
        }

        public override void Process()
        {
            base.Process();

            if (player.TryChangeState(StateCode.Fall)) return;

            float yVelocity = player.GetVelocity(1);
            animator.SetFloat("yVelocity", yVelocity);
            if (player.IsWallDetected() && (player.moveInput.x * player.FacingDirection() > 0))
                player.SetVelocity(0, yVelocity);
            else if (player.moveInput.x != 0) 
                player.SetVelocity(player.moveInput.x * player.moveSpeed, yVelocity);
        }
    }
}